package com.hqj.util;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

public class ReturnValueUtil {
    /**
     * 新增删除修改返回值
     * @return
     */
    public static Map<String,Object> aer(int i,String msg){
        Map<String,Object> map = new HashMap<>();
        if(i>0){
            map.put("msg",msg+"成功.");
            map.put("is",true);
        }else{
            map.put("msg",msg+"失败!");
            map.put("is",false);
        }
        return map;
    }
    public static Map<String,Object> aer(boolean b,String msg){
        Map<String,Object> map = new HashMap<>();
        if(b){
            map.put("msg",msg+"成功.");
        }else{
            map.put("msg",msg+"失败!");
        }
        map.put("is",b);
        return map;
    }


    public static String findData(int size,Object obj){
        Map<String,Object> data = new HashMap<>();
        data.put("code",0);
        data.put("msg","");
        data.put("count",size);
        data.put("data",obj);
        return JSON.toJSONString(data);
    }
}
